| /** |
| * Copyright (c) 2011, 2015 - 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.runtime.web.ecview.presentation.vaadin.internal.binding; |
| |
| import org.eclipse.osbp.ecview.core.common.context.IContext; |
| import org.eclipse.osbp.ecview.core.common.context.IViewContext; |
| import org.eclipse.osbp.ecview.core.common.services.IServiceProvider; |
| import org.eclipse.osbp.runtime.common.dispose.IDisposable; |
| import org.eclipse.osbp.runtime.web.ecview.presentation.vaadin.VaadinRenderer; |
| import org.eclipse.osbp.runtime.web.vaadin.databinding.VaadinObservables; |
| |
| import com.vaadin.ui.Component; |
| |
| // TODO: Auto-generated Javadoc |
| /** |
| * The Class BindingManagerProvider. |
| */ |
| public class BindingManagerProvider implements IServiceProvider { |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.osbp.ecview.core.common.services.IServiceProvider#isFor(java.lang.String, org.eclipse.osbp.ecview.core.common.context.IContext) |
| */ |
| @Override |
| public boolean isFor(String selector, IContext context) { |
| if (context instanceof IViewContext) { |
| if (!org.eclipse.osbp.ecview.core.common.binding.IECViewBindingManager.class |
| .getName().equals(selector)) { |
| return false; |
| } |
| IViewContext viewContext = (IViewContext) context; |
| if (!VaadinRenderer.UI_KIT_URI.equals(viewContext |
| .getPresentationURI())) { |
| return false; |
| } |
| return true; |
| } |
| return false; |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.osbp.ecview.core.common.services.IServiceProvider#createService(java.lang.String, org.eclipse.osbp.ecview.core.common.context.IContext) |
| */ |
| @SuppressWarnings("unchecked") |
| @Override |
| public <A> A createService(String selector, IContext context) { |
| IViewContext viewContext = (IViewContext) context; |
| final BindingManager bindingManager = new BindingManager(viewContext, |
| VaadinObservables.getRealm(VaadinObservables |
| .getUI((Component) viewContext.getRootLayout()))); |
| viewContext.addDisposeListener(new IDisposable.Listener() { |
| @Override |
| public void notifyDisposed(IDisposable notifier) { |
| bindingManager.dispose(); |
| } |
| }); |
| return (A) bindingManager; |
| } |
| |
| } |