blob: 6c217bf0373e0763c89fde6922eb2073dcd6fee1 [file] [log] [blame]
/**
* 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 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Florian Pirchner - Initial implementation
*/
package org.eclipse.osbp.runtime.web.ecview.presentation.vaadin;
import java.util.Map;
import org.eclipse.osbp.ecview.core.common.context.ContextException;
import org.eclipse.osbp.ecview.core.common.context.IViewContext;
import org.eclipse.osbp.ecview.core.common.context.ViewContext;
import org.eclipse.osbp.ecview.core.common.editpart.DelegatingEditPartManager;
import org.eclipse.osbp.ecview.core.common.editpart.IViewEditpart;
import org.eclipse.osbp.ecview.core.common.model.core.YView;
import org.eclipse.osbp.ecview.core.common.presentation.IRenderer;
import com.vaadin.ui.Component;
/**
* A special implementation for ECP that offers convenience methods.
*/
public class VaadinRenderer implements IRenderer {
/**
* URI specifying the simple SWT presentation.
*/
public static final String UI_KIT_URI = "http://osbp.eclipse.org/ecview/v1/presentation/vaadin";
/**
* Renders the UI for the given componentContainer and UI model.
*
* @param componentContainer
* The componentContainer the should be the parent for the
* rendered UI
* @param yView
* The view model.
* @param options
* rendering options
* @return viewContext - the rendered view context
* @throws ContextException
* e
*/
public IViewContext render(Object componentContainer, YView yView,
Map<String, Object> options) throws ContextException {
if (!(componentContainer instanceof Component)) {
throw new ContextException("componentContainer is not a Component");
}
ViewContext viewContext = new ViewContext();
IViewEditpart editpart = DelegatingEditPartManager.getInstance()
.getEditpart(viewContext, yView);
viewContext.setViewEditpart(editpart);
render(viewContext, componentContainer, options);
return viewContext;
}
/**
* {@inheritDoc}
*/
@Override
public void render(IViewContext viewContext, Object componentContainer,
Map<String, Object> options) throws ContextException {
viewContext.render(UI_KIT_URI, componentContainer, options);
}
}