| /** |
| * |
| * Copyright (c) 2011, 2016 - 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: |
| * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation |
| */ |
| package org.eclipse.osbp.osgi.hybrid.api; |
| |
| import java.util.HashSet; |
| import java.util.Set; |
| |
| import org.eclipse.e4.ui.model.application.ui.MElementContainer; |
| import org.eclipse.e4.ui.model.application.ui.MUIElement; |
| import org.eclipse.e4.ui.model.application.ui.advanced.MPerspectiveStack; |
| import org.eclipse.osbp.ui.api.useraccess.IUserAccessService; |
| import org.slf4j.Logger; |
| import org.slf4j.LoggerFactory; |
| |
| public class HybridServiceBinder { |
| |
| private static final Set<IPresentationRenderer> sPresentationRenderers = new HashSet<>(); |
| private final static Logger log = LoggerFactory.getLogger("servicebinder"); |
| private static IUserAccessService userAccessService; |
| |
| |
| public static void processContents(MPerspectiveStack perspectiveStack, MElementContainer<MUIElement> perspectiveStackElement) { |
| for (IPresentationRenderer presentationRenderer : sPresentationRenderers) { |
| presentationRenderer.processContents(perspectiveStack, perspectiveStackElement); |
| break; |
| } |
| } |
| |
| /** |
| * @param presentationRenderer declarative service loaded |
| */ |
| public static void bindPresentationRenderer(IPresentationRenderer presentationRenderer) { |
| log.debug(HybridServiceBinder.class.getCanonicalName()+": "+presentationRenderer.getClass().getCanonicalName()+" bound"); |
| sPresentationRenderers.add(presentationRenderer); |
| } |
| |
| /** |
| * @param presentationRenderer declarative service unloaded |
| */ |
| public static void unbindPresentationRenderer(IPresentationRenderer presentationRenderer) { |
| log.debug(HybridServiceBinder.class.getCanonicalName()+": "+presentationRenderer.getClass().getCanonicalName()+" unbound"); |
| sPresentationRenderers.remove(presentationRenderer); |
| } |
| |
| public static IUserAccessService getUserAccessService() { |
| return userAccessService; |
| } |
| |
| public synchronized void bindUserAccessService(final IUserAccessService userAccessService) { |
| this.userAccessService = userAccessService; |
| log.debug("HybridAuthenticationService bound"); |
| } |
| |
| public synchronized void unbindUserAccessService(final IUserAccessService userAccessService) { |
| this.userAccessService = null; |
| log.debug("HybridAuthenticationService unbound"); |
| } |
| |
| } |